package sv.ues.fia.clases;

import java.util.List;

import sv.ues.fia.R;
import sv.ues.fia.session.UsuarioActual;

import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.widget.TextView;

public class MainMenuAdapter extends MenuAdapter<String> {


	private final String[] ACTIVITIES_ADMIN = {"Alumno","Asesoria","DocenteAsignado","Asistencia","Ciclo","Defensa","Docente","Etapa","Integrante","Nota","Perfil","Revision","TrabajoGraduacion","Tipo","Ubicacion"};
	private final String[] ACTIVITIES_TEACHER = {"Alumno","Asesoria","DocenteAsignado","Asistencia","Defensa","Integrante","Nota","Perfil","Revision","TrabajoGraduacion"};
	private final String[] ACTIVITIES_STUDENT = {"DocenteAsignado","Defensa","Integrante","Nota","Perfil","Revision","TrabajoGraduacion"};
	
	public MainMenuAdapter(Activity ctx, List<String> elements,
			Integer bucketSize) {
		super(ctx, elements, bucketSize);
	}

	@Override
	protected View getBucketElement(final int position, String currentElement) {
		View bucketElement = View.inflate(ctx, R.layout.bucket_element, null);
				
		TextView text = (TextView)bucketElement.findViewById(R.id.text);
		text.setText(String.valueOf(currentElement));
		bucketElement.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {	
				UsuarioActual actualUser = UsuarioActual.getInstance();
				try{
					Class<?> clase=null;
					switch (actualUser.getTipoUsuario()) {
					/** Si es Administrador**/
					case UsuarioActual.ADMIN:
						clase=Class.forName("sv.ues.fia.activities."+ ACTIVITIES_ADMIN[position] +"Activity");
						break;
					/** Si es Docente**/
					case UsuarioActual.TEACHER:
						clase=Class.forName("sv.ues.fia.activities."+ ACTIVITIES_TEACHER[position] +"Activity");
						break;
					/** Si es Alumno**/
					case UsuarioActual.STUDENT:
						clase=Class.forName("sv.ues.fia.activities."+ ACTIVITIES_STUDENT[position] +"Activity");
						break;
					}
							    		
		    		Intent inte = new Intent(MainMenuAdapter.this.ctx,clase);
		    		MainMenuAdapter.this.ctx.startActivity(inte);
		    	}catch(ClassNotFoundException e){
		    		e.printStackTrace();
		    	}
			}
		});
		
		return bucketElement;
	}

}
